package com.gucheng;

import java.util.HashMap;
import java.util.Scanner;

/**
 * TwoSum（两数之和）
 */
public class TwoSumMain {

    public static int[] twoSum(int[] arr,int target){
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            int another = target - arr[i];
            if (map.containsKey(another))
            return new int[]{map.get(another),i};
            map.put(arr[i],i);
        }
        return null;
    }

}
